(function(){

var _tt;

// A module for widgets objects. populated later.
CE.WIDGETS = {
    
    // Load the widget componments.
	init: function () {
		for (module in this) {
			if (this[module].init) this[module].init();
		}
        
        this.Tooltip = FLT.CMP.Menu.extend({
            /** draws tooltip using flt menu widget
             * @param entity, the openlayers layer or vector to describe.
             * @param dom_el, the element hovered over.
             */
            update: function(entity, dom_el) {
                var x,y;
                
                if (dom_el) {
                    x = $(dom_el).offset().left;
                    y = $(dom_el).offset().top;
                } else {
                    var pixel = CE.map.getPixelFromLonLat(
                        new OpenLayers.LonLat(entity.geometry.getCentroid().x, entity.geometry.getCentroid().y));
                        x = pixel.x;
                        y = pixel.y + CE.$map.offset().top
                }
                x += 6; // let's not cover up the object of our tooltipping.
                
                this.draw().$.css({
                    left:x + 'px',
                    top:y + 'px'
                });
                this.items[0].$.text(entity.ce.title);
                this.items[0].click = function(e) {
                    if (dom_el) $(dom_el).click();
                    else CE.MEDIA.dialog(entity);
                };
            }
        })
	}
    
};

})(); // end module
